1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gobject.Value; 26 27 private import glib.Str; 28 private import glib.Variant; 29 private import glib.VariantType; 30 private import glib.c.functions; 31 private import gobject.ObjectG; 32 private import gobject.ParamSpec; 33 private import gobject.Type; 34 private import gobject.TypeInstance; 35 private import gobject.c.functions; 36 public import gobject.c.types; 37 private import std.traits; 38 39 40 /** 41 * An opaque structure used to hold different types of values. 42 * 43 * The data within the structure has protected scope: it is accessible only 44 * to functions within a #GTypeValueTable structure, or implementations of 45 * the g_value_*() API. That is, code portions which implement new fundamental 46 * types. 47 * 48 * #GValue users cannot make any assumptions about how data is stored 49 * within the 2 element @data union, and the @g_type member should 50 * only be accessed through the G_VALUE_TYPE() macro. 51 */ 52 public class Value 53 { 54 /** the main Gtk struct */ 55 protected GValue* gValue; 56 protected bool ownedRef; 57 58 /** Get the main Gtk struct */ 59 public GValue* getValueStruct(bool transferOwnership = false) 60 { 61 if (transferOwnership) 62 ownedRef = false; 63 return gValue; 64 } 65 66 /** the main Gtk struct as a void* */ 67 protected void* getStruct() 68 { 69 return cast(void*)gValue; 70 } 71 72 /** 73 * Sets our main struct and passes it to the parent class. 74 */ 75 public this (GValue* gValue, bool ownedRef = false) 76 { 77 this.gValue = gValue; 78 this.ownedRef = ownedRef; 79 } 80 81 /** */ 82 public this() 83 { 84 this(new GValue); 85 } 86 87 /** */ 88 this(GOBJECT)(GOBJECT obj) 89 if ( is(GOBJECT == class) && hasMember!(GOBJECT, "getType") ) 90 { 91 this(); 92 init(GOBJECT.getType()); 93 94 static if ( is(GOBJECT : ObjectG) ) 95 { 96 setObject(obj); 97 } 98 else 99 { 100 if ( Type.isA(gValue.gType, GType.BOXED) ) 101 setBoxed(obj.tupleof[0]); 102 else 103 setPointer(obj.tupleof[0]); 104 } 105 } 106 107 108 /** */ 109 this(string value) 110 { 111 this(); 112 init(GType.STRING); 113 setString(value); 114 } 115 116 /** */ 117 this(BOOL)(BOOL value) 118 if( isBoolean!BOOL ) 119 { 120 this(); 121 init(GType.BOOLEAN); 122 setBoolean(value); 123 } 124 125 /** */ 126 this(CHAR)(CHAR value) 127 if( is(CHAR == char) ) 128 { 129 this(); 130 init(GType.UCHAR); 131 setUchar(value); 132 } 133 134 /** */ 135 this(INT)(INT value) 136 if ( isIntegral!INT ) 137 { 138 this(); 139 140 static if ( is(OriginalType!INT == int) ) 141 { 142 init(GType.INT); 143 setInt(value); 144 } 145 else static if ( is(OriginalType!INT == uint) ) 146 { 147 init(GType.UINT); 148 setUint(value); 149 } 150 else static if ( is(OriginalType!INT == long) ) 151 { 152 init(GType.INT64); 153 setInt64(value); 154 } 155 else static if ( is(OriginalType!INT == ulong) ) 156 { 157 init(GType.UINT64); 158 setUint64(value); 159 } 160 else 161 { 162 init(GType.INT); 163 setInt(value); 164 } 165 } 166 167 /** */ 168 this(FLOAT)(FLOAT value) 169 if ( isFloatingPoint!FLOAT ) 170 { 171 this(); 172 173 static if ( is( FLOAT == float ) ) 174 { 175 init(GType.FLOAT); 176 setFloat(value); 177 } 178 else 179 { 180 init(GType.DOUBLE); 181 setDouble(value); 182 } 183 } 184 185 /** 186 * The GType of the contianed value. 187 */ 188 public @property GType gType() 189 { 190 return gValue.gType; 191 } 192 193 /** 194 * Retrieves a TYPE from Value, the Value must contain the appropriate type. 195 */ 196 public TYPE get(TYPE)() 197 { 198 static if ( is(TYPE == bool) ) 199 return getBoolean(); 200 else static if ( is(TYPE == byte) ) 201 return getSchar(); 202 else static if ( is(TYPE == ubyte) || is(TYPE == char) ) 203 return getUchar(); 204 else static if ( is(TYPE == int) ) 205 return getInt(); 206 else static if ( is(TYPE == uint) ) 207 return getUint(); 208 else static if ( is(TYPE == long) ) 209 return getInt64(); 210 else static if ( is(TYPE == ulong) ) 211 return getUint64(); 212 else static if ( is(TYPE == float) ) 213 return getFloat(); 214 else static if ( is(TYPE == double) ) 215 return getDouble(); 216 else static if ( is(TYPE == string) ) 217 return getString(); 218 else static if ( is(TYPE == string[]) ) 219 return Str.toStringArray(cast(const(char*)*)getPointer()); 220 else static if ( is(TYPE == enum) ) 221 return cast(TYPE)(Type.isA(gValue.gType, GType.ENUM) ? getEnum() : getFlags()); 222 else static if ( isPointer!TYPE ) 223 return cast(TYPE)(Type.isA(gValue.gType, GType.POINTER) ? getPointer() : (Type.isA(gValue.gType, GType.BOXED) ? getBoxed() : g_value_get_object(gValue))); 224 else static if ( is(TYPE == interface) ) 225 return cast(TYPE)getObject(); 226 else static if ( is(TYPE == class) ) 227 { 228 static if ( is(TYPE == Variant) ) 229 return getVariant(); 230 else static if ( is(TYPE== ParamSpec) ) 231 return getParam(); 232 else static if ( is(TYPE : ObjectG) ) 233 return cast(TYPE)getObject(); 234 else 235 return ObjectG.getDObject!(TYPE)(cast(typeof(TYPE.tupleof[0]))(Type.isA(gValue.gType, GType.POINTER) ? getPointer() : (Type.isA(gValue.gType, GType.BOXED) ? getBoxed() : g_value_get_object(gValue)))); 236 } 237 } 238 239 /** 240 */ 241 242 /** */ 243 public static GType getType() 244 { 245 return g_value_get_type(); 246 } 247 248 /** 249 * Copies the value of @src_value into @dest_value. 250 * 251 * Params: 252 * destValue = An initialized #GValue structure of the same type as @src_value. 253 */ 254 public void copy(Value destValue) 255 { 256 g_value_copy(gValue, (destValue is null) ? null : destValue.getValueStruct()); 257 } 258 259 /** 260 * Get the contents of a %G_TYPE_BOXED derived #GValue. Upon getting, 261 * the boxed value is duplicated and needs to be later freed with 262 * g_boxed_free(), e.g. like: g_boxed_free (G_VALUE_TYPE (@value), 263 * return_value); 264 * 265 * Returns: boxed contents of @value 266 */ 267 public void* dupBoxed() 268 { 269 return g_value_dup_boxed(gValue); 270 } 271 272 /** 273 * Get the contents of a %G_TYPE_OBJECT derived #GValue, increasing 274 * its reference count. If the contents of the #GValue are %NULL, then 275 * %NULL will be returned. 276 * 277 * Returns: object content of @value, 278 * should be unreferenced when no longer needed. 279 */ 280 public ObjectG dupObject() 281 { 282 auto __p = g_value_dup_object(gValue); 283 284 if(__p is null) 285 { 286 return null; 287 } 288 289 return ObjectG.getDObject!(ObjectG)(cast(GObject*) __p, true); 290 } 291 292 /** 293 * Get the contents of a %G_TYPE_PARAM #GValue, increasing its 294 * reference count. 295 * 296 * Returns: #GParamSpec content of @value, should be 297 * unreferenced when no longer needed. 298 */ 299 public ParamSpec dupParam() 300 { 301 auto __p = g_value_dup_param(gValue); 302 303 if(__p is null) 304 { 305 return null; 306 } 307 308 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 309 } 310 311 /** 312 * Get a copy the contents of a %G_TYPE_STRING #GValue. 313 * 314 * Returns: a newly allocated copy of the string content of @value 315 */ 316 public string dupString() 317 { 318 auto retStr = g_value_dup_string(gValue); 319 320 scope(exit) Str.freeString(retStr); 321 return Str.toString(retStr); 322 } 323 324 /** 325 * Get the contents of a variant #GValue, increasing its refcount. The returned 326 * #GVariant is never floating. 327 * 328 * Returns: variant contents of @value (may be %NULL); 329 * should be unreffed using g_variant_unref() when no longer needed 330 * 331 * Since: 2.26 332 */ 333 public Variant dupVariant() 334 { 335 auto __p = g_value_dup_variant(gValue); 336 337 if(__p is null) 338 { 339 return null; 340 } 341 342 return new Variant(cast(GVariant*) __p, true); 343 } 344 345 /** 346 * Determines if @value will fit inside the size of a pointer value. 347 * This is an internal function introduced mainly for C marshallers. 348 * 349 * Returns: %TRUE if @value will fit inside a pointer value. 350 */ 351 public bool fitsPointer() 352 { 353 return g_value_fits_pointer(gValue) != 0; 354 } 355 356 /** 357 * Get the contents of a %G_TYPE_BOOLEAN #GValue. 358 * 359 * Returns: boolean contents of @value 360 */ 361 public bool getBoolean() 362 { 363 return g_value_get_boolean(gValue) != 0; 364 } 365 366 /** 367 * Get the contents of a %G_TYPE_BOXED derived #GValue. 368 * 369 * Returns: boxed contents of @value 370 */ 371 public void* getBoxed() 372 { 373 return g_value_get_boxed(gValue); 374 } 375 376 /** 377 * Do not use this function; it is broken on platforms where the %char 378 * type is unsigned, such as ARM and PowerPC. See g_value_get_schar(). 379 * 380 * Get the contents of a %G_TYPE_CHAR #GValue. 381 * 382 * Deprecated: This function's return type is broken, see g_value_get_schar() 383 * 384 * Returns: character contents of @value 385 */ 386 public char getChar() 387 { 388 return g_value_get_char(gValue); 389 } 390 391 /** 392 * Get the contents of a %G_TYPE_DOUBLE #GValue. 393 * 394 * Returns: double contents of @value 395 */ 396 public double getDouble() 397 { 398 return g_value_get_double(gValue); 399 } 400 401 /** 402 * Get the contents of a %G_TYPE_ENUM #GValue. 403 * 404 * Returns: enum contents of @value 405 */ 406 public int getEnum() 407 { 408 return g_value_get_enum(gValue); 409 } 410 411 /** 412 * Get the contents of a %G_TYPE_FLAGS #GValue. 413 * 414 * Returns: flags contents of @value 415 */ 416 public uint getFlags() 417 { 418 return g_value_get_flags(gValue); 419 } 420 421 /** 422 * Get the contents of a %G_TYPE_FLOAT #GValue. 423 * 424 * Returns: float contents of @value 425 */ 426 public float getFloat() 427 { 428 return g_value_get_float(gValue); 429 } 430 431 /** 432 * Get the contents of a %G_TYPE_GTYPE #GValue. 433 * 434 * Returns: the #GType stored in @value 435 * 436 * Since: 2.12 437 */ 438 public GType getGtype() 439 { 440 return g_value_get_gtype(gValue); 441 } 442 443 /** 444 * Get the contents of a %G_TYPE_INT #GValue. 445 * 446 * Returns: integer contents of @value 447 */ 448 public int getInt() 449 { 450 return g_value_get_int(gValue); 451 } 452 453 /** 454 * Get the contents of a %G_TYPE_INT64 #GValue. 455 * 456 * Returns: 64bit integer contents of @value 457 */ 458 public long getInt64() 459 { 460 return g_value_get_int64(gValue); 461 } 462 463 /** 464 * Get the contents of a %G_TYPE_LONG #GValue. 465 * 466 * Returns: long integer contents of @value 467 */ 468 public glong getLong() 469 { 470 return g_value_get_long(gValue); 471 } 472 473 /** 474 * Get the contents of a %G_TYPE_OBJECT derived #GValue. 475 * 476 * Returns: object contents of @value 477 */ 478 public ObjectG getObject() 479 { 480 auto __p = g_value_get_object(gValue); 481 482 if(__p is null) 483 { 484 return null; 485 } 486 487 return ObjectG.getDObject!(ObjectG)(cast(GObject*) __p); 488 } 489 490 /** 491 * Get the contents of a %G_TYPE_PARAM #GValue. 492 * 493 * Returns: #GParamSpec content of @value 494 */ 495 public ParamSpec getParam() 496 { 497 auto __p = g_value_get_param(gValue); 498 499 if(__p is null) 500 { 501 return null; 502 } 503 504 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p); 505 } 506 507 /** 508 * Get the contents of a pointer #GValue. 509 * 510 * Returns: pointer contents of @value 511 */ 512 public void* getPointer() 513 { 514 return g_value_get_pointer(gValue); 515 } 516 517 /** 518 * Get the contents of a %G_TYPE_CHAR #GValue. 519 * 520 * Returns: signed 8 bit integer contents of @value 521 * 522 * Since: 2.32 523 */ 524 public byte getSchar() 525 { 526 return g_value_get_schar(gValue); 527 } 528 529 /** 530 * Get the contents of a %G_TYPE_STRING #GValue. 531 * 532 * Returns: string content of @value 533 */ 534 public string getString() 535 { 536 return Str.toString(g_value_get_string(gValue)); 537 } 538 539 /** 540 * Get the contents of a %G_TYPE_UCHAR #GValue. 541 * 542 * Returns: unsigned character contents of @value 543 */ 544 public char getUchar() 545 { 546 return g_value_get_uchar(gValue); 547 } 548 549 /** 550 * Get the contents of a %G_TYPE_UINT #GValue. 551 * 552 * Returns: unsigned integer contents of @value 553 */ 554 public uint getUint() 555 { 556 return g_value_get_uint(gValue); 557 } 558 559 /** 560 * Get the contents of a %G_TYPE_UINT64 #GValue. 561 * 562 * Returns: unsigned 64bit integer contents of @value 563 */ 564 public ulong getUint64() 565 { 566 return g_value_get_uint64(gValue); 567 } 568 569 /** 570 * Get the contents of a %G_TYPE_ULONG #GValue. 571 * 572 * Returns: unsigned long integer contents of @value 573 */ 574 public gulong getUlong() 575 { 576 return g_value_get_ulong(gValue); 577 } 578 579 /** 580 * Get the contents of a variant #GValue. 581 * 582 * Returns: variant contents of @value (may be %NULL) 583 * 584 * Since: 2.26 585 */ 586 public Variant getVariant() 587 { 588 auto __p = g_value_get_variant(gValue); 589 590 if(__p is null) 591 { 592 return null; 593 } 594 595 return new Variant(cast(GVariant*) __p); 596 } 597 598 /** 599 * Initializes @value with the default value of @type. 600 * 601 * Params: 602 * gType = Type the #GValue should hold values of. 603 * 604 * Returns: the #GValue structure that has been passed in 605 */ 606 public Value init(GType gType) 607 { 608 auto __p = g_value_init(gValue, gType); 609 610 if(__p is null) 611 { 612 return null; 613 } 614 615 return ObjectG.getDObject!(Value)(cast(GValue*) __p); 616 } 617 618 /** 619 * Initializes and sets @value from an instantiatable type via the 620 * value_table's collect_value() function. 621 * 622 * Note: The @value will be initialised with the exact type of 623 * @instance. If you wish to set the @value's type to a different GType 624 * (such as a parent class GType), you need to manually call 625 * g_value_init() and g_value_set_instance(). 626 * 627 * Params: 628 * instance_ = the instance 629 * 630 * Since: 2.42 631 */ 632 public void initFromInstance(TypeInstance instance_) 633 { 634 g_value_init_from_instance(gValue, (instance_ is null) ? null : instance_.getTypeInstanceStruct()); 635 } 636 637 /** 638 * Returns the value contents as pointer. This function asserts that 639 * g_value_fits_pointer() returned %TRUE for the passed in value. 640 * This is an internal function introduced mainly for C marshallers. 641 * 642 * Returns: the value contents as pointer 643 */ 644 public void* peekPointer() 645 { 646 return g_value_peek_pointer(gValue); 647 } 648 649 /** 650 * Clears the current value in @value and resets it to the default value 651 * (as if the value had just been initialized). 652 * 653 * Returns: the #GValue structure that has been passed in 654 */ 655 public Value reset() 656 { 657 auto __p = g_value_reset(gValue); 658 659 if(__p is null) 660 { 661 return null; 662 } 663 664 return ObjectG.getDObject!(Value)(cast(GValue*) __p, true); 665 } 666 667 /** 668 * Set the contents of a %G_TYPE_BOOLEAN #GValue to @v_boolean. 669 * 670 * Params: 671 * vBoolean = boolean value to be set 672 */ 673 public void setBoolean(bool vBoolean) 674 { 675 g_value_set_boolean(gValue, vBoolean); 676 } 677 678 /** 679 * Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed. 680 * 681 * Params: 682 * vBoxed = boxed value to be set 683 */ 684 public void setBoxed(void* vBoxed) 685 { 686 g_value_set_boxed(gValue, vBoxed); 687 } 688 689 /** 690 * This is an internal function introduced mainly for C marshallers. 691 * 692 * Deprecated: Use g_value_take_boxed() instead. 693 * 694 * Params: 695 * vBoxed = duplicated unowned boxed value to be set 696 */ 697 public void setBoxedTakeOwnership(void* vBoxed) 698 { 699 g_value_set_boxed_take_ownership(gValue, vBoxed); 700 } 701 702 /** 703 * Set the contents of a %G_TYPE_CHAR #GValue to @v_char. 704 * 705 * Deprecated: This function's input type is broken, see g_value_set_schar() 706 * 707 * Params: 708 * vChar = character value to be set 709 */ 710 public void setChar(char vChar) 711 { 712 g_value_set_char(gValue, vChar); 713 } 714 715 /** 716 * Set the contents of a %G_TYPE_DOUBLE #GValue to @v_double. 717 * 718 * Params: 719 * vDouble = double value to be set 720 */ 721 public void setDouble(double vDouble) 722 { 723 g_value_set_double(gValue, vDouble); 724 } 725 726 /** 727 * Set the contents of a %G_TYPE_ENUM #GValue to @v_enum. 728 * 729 * Params: 730 * vEnum = enum value to be set 731 */ 732 public void setEnum(int vEnum) 733 { 734 g_value_set_enum(gValue, vEnum); 735 } 736 737 /** 738 * Set the contents of a %G_TYPE_FLAGS #GValue to @v_flags. 739 * 740 * Params: 741 * vFlags = flags value to be set 742 */ 743 public void setFlags(uint vFlags) 744 { 745 g_value_set_flags(gValue, vFlags); 746 } 747 748 /** 749 * Set the contents of a %G_TYPE_FLOAT #GValue to @v_float. 750 * 751 * Params: 752 * vFloat = float value to be set 753 */ 754 public void setFloat(float vFloat) 755 { 756 g_value_set_float(gValue, vFloat); 757 } 758 759 /** 760 * Set the contents of a %G_TYPE_GTYPE #GValue to @v_gtype. 761 * 762 * Params: 763 * vGtype = #GType to be set 764 * 765 * Since: 2.12 766 */ 767 public void setGtype(GType vGtype) 768 { 769 g_value_set_gtype(gValue, vGtype); 770 } 771 772 /** 773 * Sets @value from an instantiatable type via the 774 * value_table's collect_value() function. 775 * 776 * Params: 777 * instance_ = the instance 778 */ 779 public void setInstance(void* instance_) 780 { 781 g_value_set_instance(gValue, instance_); 782 } 783 784 /** 785 * Set the contents of a %G_TYPE_INT #GValue to @v_int. 786 * 787 * Params: 788 * vInt = integer value to be set 789 */ 790 public void setInt(int vInt) 791 { 792 g_value_set_int(gValue, vInt); 793 } 794 795 /** 796 * Set the contents of a %G_TYPE_INT64 #GValue to @v_int64. 797 * 798 * Params: 799 * vInt64 = 64bit integer value to be set 800 */ 801 public void setInt64(long vInt64) 802 { 803 g_value_set_int64(gValue, vInt64); 804 } 805 806 /** 807 * Set the contents of a %G_TYPE_STRING #GValue to @v_string. The string is 808 * assumed to be static and interned (canonical, for example from 809 * g_intern_string()), and is thus not duplicated when setting the #GValue. 810 * 811 * Params: 812 * vString = static string to be set 813 * 814 * Since: 2.66 815 */ 816 public void setInternedString(string vString) 817 { 818 g_value_set_interned_string(gValue, Str.toStringz(vString)); 819 } 820 821 /** 822 * Set the contents of a %G_TYPE_LONG #GValue to @v_long. 823 * 824 * Params: 825 * vLong = long integer value to be set 826 */ 827 public void setLong(glong vLong) 828 { 829 g_value_set_long(gValue, vLong); 830 } 831 832 /** 833 * Set the contents of a %G_TYPE_OBJECT derived #GValue to @v_object. 834 * 835 * g_value_set_object() increases the reference count of @v_object 836 * (the #GValue holds a reference to @v_object). If you do not wish 837 * to increase the reference count of the object (i.e. you wish to 838 * pass your current reference to the #GValue because you no longer 839 * need it), use g_value_take_object() instead. 840 * 841 * It is important that your #GValue holds a reference to @v_object (either its 842 * own, or one it has taken) to ensure that the object won't be destroyed while 843 * the #GValue still exists). 844 * 845 * Params: 846 * vObject = object value to be set 847 */ 848 public void setObject(ObjectG vObject) 849 { 850 g_value_set_object(gValue, (vObject is null) ? null : vObject.getObjectGStruct()); 851 } 852 853 /** 854 * This is an internal function introduced mainly for C marshallers. 855 * 856 * Deprecated: Use g_value_take_object() instead. 857 * 858 * Params: 859 * vObject = object value to be set 860 */ 861 public void setObjectTakeOwnership(void* vObject) 862 { 863 g_value_set_object_take_ownership(gValue, vObject); 864 } 865 866 /** 867 * Set the contents of a %G_TYPE_PARAM #GValue to @param. 868 * 869 * Params: 870 * param = the #GParamSpec to be set 871 */ 872 public void setParam(ParamSpec param) 873 { 874 g_value_set_param(gValue, (param is null) ? null : param.getParamSpecStruct()); 875 } 876 877 /** 878 * This is an internal function introduced mainly for C marshallers. 879 * 880 * Deprecated: Use g_value_take_param() instead. 881 * 882 * Params: 883 * param = the #GParamSpec to be set 884 */ 885 public void setParamTakeOwnership(ParamSpec param) 886 { 887 g_value_set_param_take_ownership(gValue, (param is null) ? null : param.getParamSpecStruct()); 888 } 889 890 /** 891 * Set the contents of a pointer #GValue to @v_pointer. 892 * 893 * Params: 894 * vPointer = pointer value to be set 895 */ 896 public void setPointer(void* vPointer) 897 { 898 g_value_set_pointer(gValue, vPointer); 899 } 900 901 /** 902 * Set the contents of a %G_TYPE_CHAR #GValue to @v_char. 903 * 904 * Params: 905 * vChar = signed 8 bit integer to be set 906 * 907 * Since: 2.32 908 */ 909 public void setSchar(byte vChar) 910 { 911 g_value_set_schar(gValue, vChar); 912 } 913 914 /** 915 * Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed. 916 * 917 * The boxed value is assumed to be static, and is thus not duplicated 918 * when setting the #GValue. 919 * 920 * Params: 921 * vBoxed = static boxed value to be set 922 */ 923 public void setStaticBoxed(void* vBoxed) 924 { 925 g_value_set_static_boxed(gValue, vBoxed); 926 } 927 928 /** 929 * Set the contents of a %G_TYPE_STRING #GValue to @v_string. 930 * The string is assumed to be static, and is thus not duplicated 931 * when setting the #GValue. 932 * 933 * If the the string is a canonical string, using g_value_set_interned_string() 934 * is more appropriate. 935 * 936 * Params: 937 * vString = static string to be set 938 */ 939 public void setStaticString(string vString) 940 { 941 g_value_set_static_string(gValue, Str.toStringz(vString)); 942 } 943 944 /** 945 * Set the contents of a %G_TYPE_STRING #GValue to a copy of @v_string. 946 * 947 * Params: 948 * vString = caller-owned string to be duplicated for the #GValue 949 */ 950 public void setString(string vString) 951 { 952 g_value_set_string(gValue, Str.toStringz(vString)); 953 } 954 955 /** 956 * This is an internal function introduced mainly for C marshallers. 957 * 958 * Deprecated: Use g_value_take_string() instead. 959 * 960 * Params: 961 * vString = duplicated unowned string to be set 962 */ 963 public void setStringTakeOwnership(string vString) 964 { 965 g_value_set_string_take_ownership(gValue, Str.toStringz(vString)); 966 } 967 968 /** 969 * Set the contents of a %G_TYPE_UCHAR #GValue to @v_uchar. 970 * 971 * Params: 972 * vUchar = unsigned character value to be set 973 */ 974 public void setUchar(char vUchar) 975 { 976 g_value_set_uchar(gValue, vUchar); 977 } 978 979 /** 980 * Set the contents of a %G_TYPE_UINT #GValue to @v_uint. 981 * 982 * Params: 983 * vUint = unsigned integer value to be set 984 */ 985 public void setUint(uint vUint) 986 { 987 g_value_set_uint(gValue, vUint); 988 } 989 990 /** 991 * Set the contents of a %G_TYPE_UINT64 #GValue to @v_uint64. 992 * 993 * Params: 994 * vUint64 = unsigned 64bit integer value to be set 995 */ 996 public void setUint64(ulong vUint64) 997 { 998 g_value_set_uint64(gValue, vUint64); 999 } 1000 1001 /** 1002 * Set the contents of a %G_TYPE_ULONG #GValue to @v_ulong. 1003 * 1004 * Params: 1005 * vUlong = unsigned long integer value to be set 1006 */ 1007 public void setUlong(gulong vUlong) 1008 { 1009 g_value_set_ulong(gValue, vUlong); 1010 } 1011 1012 /** 1013 * Set the contents of a variant #GValue to @variant. 1014 * If the variant is floating, it is consumed. 1015 * 1016 * Params: 1017 * variant = a #GVariant, or %NULL 1018 * 1019 * Since: 2.26 1020 */ 1021 public void setVariant(Variant variant) 1022 { 1023 g_value_set_variant(gValue, (variant is null) ? null : variant.getVariantStruct()); 1024 } 1025 1026 /** 1027 * Sets the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed 1028 * and takes over the ownership of the caller’s reference to @v_boxed; 1029 * the caller doesn’t have to unref it any more. 1030 * 1031 * Params: 1032 * vBoxed = duplicated unowned boxed value to be set 1033 * 1034 * Since: 2.4 1035 */ 1036 public void takeBoxed(void* vBoxed) 1037 { 1038 g_value_take_boxed(gValue, vBoxed); 1039 } 1040 1041 /** 1042 * Sets the contents of a %G_TYPE_OBJECT derived #GValue to @v_object 1043 * and takes over the ownership of the caller’s reference to @v_object; 1044 * the caller doesn’t have to unref it any more (i.e. the reference 1045 * count of the object is not increased). 1046 * 1047 * If you want the #GValue to hold its own reference to @v_object, use 1048 * g_value_set_object() instead. 1049 * 1050 * Params: 1051 * vObject = object value to be set 1052 * 1053 * Since: 2.4 1054 */ 1055 public void takeObject(void* vObject) 1056 { 1057 g_value_take_object(gValue, vObject); 1058 } 1059 1060 /** 1061 * Sets the contents of a %G_TYPE_PARAM #GValue to @param and takes 1062 * over the ownership of the caller’s reference to @param; the caller 1063 * doesn’t have to unref it any more. 1064 * 1065 * Params: 1066 * param = the #GParamSpec to be set 1067 * 1068 * Since: 2.4 1069 */ 1070 public void takeParam(ParamSpec param) 1071 { 1072 g_value_take_param(gValue, (param is null) ? null : param.getParamSpecStruct()); 1073 } 1074 1075 /** 1076 * Sets the contents of a %G_TYPE_STRING #GValue to @v_string. 1077 * 1078 * Params: 1079 * vString = string to take ownership of 1080 * 1081 * Since: 2.4 1082 */ 1083 public void takeString(string vString) 1084 { 1085 g_value_take_string(gValue, Str.toStringz(vString)); 1086 } 1087 1088 /** 1089 * Set the contents of a variant #GValue to @variant, and takes over 1090 * the ownership of the caller's reference to @variant; 1091 * the caller doesn't have to unref it any more (i.e. the reference 1092 * count of the variant is not increased). 1093 * 1094 * If @variant was floating then its floating reference is converted to 1095 * a hard reference. 1096 * 1097 * If you want the #GValue to hold its own reference to @variant, use 1098 * g_value_set_variant() instead. 1099 * 1100 * This is an internal function introduced mainly for C marshallers. 1101 * 1102 * Params: 1103 * variant = a #GVariant, or %NULL 1104 * 1105 * Since: 2.26 1106 */ 1107 public void takeVariant(Variant variant) 1108 { 1109 g_value_take_variant(gValue, (variant is null) ? null : variant.getVariantStruct(true)); 1110 } 1111 1112 /** 1113 * Tries to cast the contents of @src_value into a type appropriate 1114 * to store in @dest_value, e.g. to transform a %G_TYPE_INT value 1115 * into a %G_TYPE_FLOAT value. Performing transformations between 1116 * value types might incur precision lossage. Especially 1117 * transformations into strings might reveal seemingly arbitrary 1118 * results and shouldn't be relied upon for production code (such 1119 * as rcfile value or object property serialization). 1120 * 1121 * Params: 1122 * destValue = Target value. 1123 * 1124 * Returns: Whether a transformation rule was found and could be applied. 1125 * Upon failing transformations, @dest_value is left untouched. 1126 */ 1127 public bool transform(Value destValue) 1128 { 1129 return g_value_transform(gValue, (destValue is null) ? null : destValue.getValueStruct()) != 0; 1130 } 1131 1132 /** 1133 * Clears the current value in @value (if any) and "unsets" the type, 1134 * this releases all resources associated with this GValue. An unset 1135 * value is the same as an uninitialized (zero-filled) #GValue 1136 * structure. 1137 */ 1138 public void unset() 1139 { 1140 g_value_unset(gValue); 1141 } 1142 1143 /** 1144 * Registers a value transformation function for use in g_value_transform(). 1145 * A previously registered transformation function for @src_type and @dest_type 1146 * will be replaced. 1147 * 1148 * Params: 1149 * srcType = Source type. 1150 * destType = Target type. 1151 * transformFunc = a function which transforms values of type @src_type 1152 * into value of type @dest_type 1153 */ 1154 public static void registerTransformFunc(GType srcType, GType destType, GValueTransform transformFunc) 1155 { 1156 g_value_register_transform_func(srcType, destType, transformFunc); 1157 } 1158 1159 /** 1160 * Returns whether a #GValue of type @src_type can be copied into 1161 * a #GValue of type @dest_type. 1162 * 1163 * Params: 1164 * srcType = source type to be copied. 1165 * destType = destination type for copying. 1166 * 1167 * Returns: %TRUE if g_value_copy() is possible with @src_type and @dest_type. 1168 */ 1169 public static bool typeCompatible(GType srcType, GType destType) 1170 { 1171 return g_value_type_compatible(srcType, destType) != 0; 1172 } 1173 1174 /** 1175 * Check whether g_value_transform() is able to transform values 1176 * of type @src_type into values of type @dest_type. Note that for 1177 * the types to be transformable, they must be compatible or a 1178 * transformation function must be registered. 1179 * 1180 * Params: 1181 * srcType = Source type. 1182 * destType = Target type. 1183 * 1184 * Returns: %TRUE if the transformation is possible, %FALSE otherwise. 1185 */ 1186 public static bool typeTransformable(GType srcType, GType destType) 1187 { 1188 return g_value_type_transformable(srcType, destType) != 0; 1189 } 1190 1191 /** 1192 * Creates a new #GParamSpecBoolean instance specifying a %G_TYPE_BOOLEAN 1193 * property. In many cases, it may be more appropriate to use an enum with 1194 * g_param_spec_enum(), both to improve code clarity by using explicitly named 1195 * values, and to allow for more values to be added in future without breaking 1196 * API. 1197 * 1198 * See g_param_spec_internal() for details on property names. 1199 * 1200 * Params: 1201 * name = canonical name of the property specified 1202 * nick = nick name for the property specified 1203 * blurb = description of the property specified 1204 * defaultValue = default value for the property specified 1205 * flags = flags for the property specified 1206 * 1207 * Returns: a newly created parameter specification 1208 */ 1209 public static ParamSpec paramSpecBoolean(string name, string nick, string blurb, bool defaultValue, GParamFlags flags) 1210 { 1211 auto __p = g_param_spec_boolean(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), defaultValue, flags); 1212 1213 if(__p is null) 1214 { 1215 return null; 1216 } 1217 1218 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1219 } 1220 1221 /** 1222 * Creates a new #GParamSpecBoxed instance specifying a %G_TYPE_BOXED 1223 * derived property. 1224 * 1225 * See g_param_spec_internal() for details on property names. 1226 * 1227 * Params: 1228 * name = canonical name of the property specified 1229 * nick = nick name for the property specified 1230 * blurb = description of the property specified 1231 * boxedType = %G_TYPE_BOXED derived type of this property 1232 * flags = flags for the property specified 1233 * 1234 * Returns: a newly created parameter specification 1235 */ 1236 public static ParamSpec paramSpecBoxed(string name, string nick, string blurb, GType boxedType, GParamFlags flags) 1237 { 1238 auto __p = g_param_spec_boxed(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), boxedType, flags); 1239 1240 if(__p is null) 1241 { 1242 return null; 1243 } 1244 1245 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1246 } 1247 1248 /** 1249 * Creates a new #GParamSpecChar instance specifying a %G_TYPE_CHAR property. 1250 * 1251 * Params: 1252 * name = canonical name of the property specified 1253 * nick = nick name for the property specified 1254 * blurb = description of the property specified 1255 * minimum = minimum value for the property specified 1256 * maximum = maximum value for the property specified 1257 * defaultValue = default value for the property specified 1258 * flags = flags for the property specified 1259 * 1260 * Returns: a newly created parameter specification 1261 */ 1262 public static ParamSpec paramSpecChar(string name, string nick, string blurb, byte minimum, byte maximum, byte defaultValue, GParamFlags flags) 1263 { 1264 auto __p = g_param_spec_char(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1265 1266 if(__p is null) 1267 { 1268 return null; 1269 } 1270 1271 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1272 } 1273 1274 /** 1275 * Creates a new #GParamSpecDouble instance specifying a %G_TYPE_DOUBLE 1276 * property. 1277 * 1278 * See g_param_spec_internal() for details on property names. 1279 * 1280 * Params: 1281 * name = canonical name of the property specified 1282 * nick = nick name for the property specified 1283 * blurb = description of the property specified 1284 * minimum = minimum value for the property specified 1285 * maximum = maximum value for the property specified 1286 * defaultValue = default value for the property specified 1287 * flags = flags for the property specified 1288 * 1289 * Returns: a newly created parameter specification 1290 */ 1291 public static ParamSpec paramSpecDouble(string name, string nick, string blurb, double minimum, double maximum, double defaultValue, GParamFlags flags) 1292 { 1293 auto __p = g_param_spec_double(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1294 1295 if(__p is null) 1296 { 1297 return null; 1298 } 1299 1300 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1301 } 1302 1303 /** 1304 * Creates a new #GParamSpecEnum instance specifying a %G_TYPE_ENUM 1305 * property. 1306 * 1307 * See g_param_spec_internal() for details on property names. 1308 * 1309 * Params: 1310 * name = canonical name of the property specified 1311 * nick = nick name for the property specified 1312 * blurb = description of the property specified 1313 * enumType = a #GType derived from %G_TYPE_ENUM 1314 * defaultValue = default value for the property specified 1315 * flags = flags for the property specified 1316 * 1317 * Returns: a newly created parameter specification 1318 */ 1319 public static ParamSpec paramSpecEnum(string name, string nick, string blurb, GType enumType, int defaultValue, GParamFlags flags) 1320 { 1321 auto __p = g_param_spec_enum(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), enumType, defaultValue, flags); 1322 1323 if(__p is null) 1324 { 1325 return null; 1326 } 1327 1328 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1329 } 1330 1331 /** 1332 * Creates a new #GParamSpecFlags instance specifying a %G_TYPE_FLAGS 1333 * property. 1334 * 1335 * See g_param_spec_internal() for details on property names. 1336 * 1337 * Params: 1338 * name = canonical name of the property specified 1339 * nick = nick name for the property specified 1340 * blurb = description of the property specified 1341 * flagsType = a #GType derived from %G_TYPE_FLAGS 1342 * defaultValue = default value for the property specified 1343 * flags = flags for the property specified 1344 * 1345 * Returns: a newly created parameter specification 1346 */ 1347 public static ParamSpec paramSpecFlags(string name, string nick, string blurb, GType flagsType, uint defaultValue, GParamFlags flags) 1348 { 1349 auto __p = g_param_spec_flags(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), flagsType, defaultValue, flags); 1350 1351 if(__p is null) 1352 { 1353 return null; 1354 } 1355 1356 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1357 } 1358 1359 /** 1360 * Creates a new #GParamSpecFloat instance specifying a %G_TYPE_FLOAT property. 1361 * 1362 * See g_param_spec_internal() for details on property names. 1363 * 1364 * Params: 1365 * name = canonical name of the property specified 1366 * nick = nick name for the property specified 1367 * blurb = description of the property specified 1368 * minimum = minimum value for the property specified 1369 * maximum = maximum value for the property specified 1370 * defaultValue = default value for the property specified 1371 * flags = flags for the property specified 1372 * 1373 * Returns: a newly created parameter specification 1374 */ 1375 public static ParamSpec paramSpecFloat(string name, string nick, string blurb, float minimum, float maximum, float defaultValue, GParamFlags flags) 1376 { 1377 auto __p = g_param_spec_float(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1378 1379 if(__p is null) 1380 { 1381 return null; 1382 } 1383 1384 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1385 } 1386 1387 /** 1388 * Creates a new #GParamSpecGType instance specifying a 1389 * %G_TYPE_GTYPE property. 1390 * 1391 * See g_param_spec_internal() for details on property names. 1392 * 1393 * Params: 1394 * name = canonical name of the property specified 1395 * nick = nick name for the property specified 1396 * blurb = description of the property specified 1397 * isAType = a #GType whose subtypes are allowed as values 1398 * of the property (use %G_TYPE_NONE for any type) 1399 * flags = flags for the property specified 1400 * 1401 * Returns: a newly created parameter specification 1402 * 1403 * Since: 2.10 1404 */ 1405 public static ParamSpec paramSpecGtype(string name, string nick, string blurb, GType isAType, GParamFlags flags) 1406 { 1407 auto __p = g_param_spec_gtype(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), isAType, flags); 1408 1409 if(__p is null) 1410 { 1411 return null; 1412 } 1413 1414 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1415 } 1416 1417 /** 1418 * Creates a new #GParamSpecInt instance specifying a %G_TYPE_INT property. 1419 * 1420 * See g_param_spec_internal() for details on property names. 1421 * 1422 * Params: 1423 * name = canonical name of the property specified 1424 * nick = nick name for the property specified 1425 * blurb = description of the property specified 1426 * minimum = minimum value for the property specified 1427 * maximum = maximum value for the property specified 1428 * defaultValue = default value for the property specified 1429 * flags = flags for the property specified 1430 * 1431 * Returns: a newly created parameter specification 1432 */ 1433 public static ParamSpec paramSpecInt(string name, string nick, string blurb, int minimum, int maximum, int defaultValue, GParamFlags flags) 1434 { 1435 auto __p = g_param_spec_int(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1436 1437 if(__p is null) 1438 { 1439 return null; 1440 } 1441 1442 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1443 } 1444 1445 /** 1446 * Creates a new #GParamSpecInt64 instance specifying a %G_TYPE_INT64 property. 1447 * 1448 * See g_param_spec_internal() for details on property names. 1449 * 1450 * Params: 1451 * name = canonical name of the property specified 1452 * nick = nick name for the property specified 1453 * blurb = description of the property specified 1454 * minimum = minimum value for the property specified 1455 * maximum = maximum value for the property specified 1456 * defaultValue = default value for the property specified 1457 * flags = flags for the property specified 1458 * 1459 * Returns: a newly created parameter specification 1460 */ 1461 public static ParamSpec paramSpecInt64(string name, string nick, string blurb, long minimum, long maximum, long defaultValue, GParamFlags flags) 1462 { 1463 auto __p = g_param_spec_int64(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1464 1465 if(__p is null) 1466 { 1467 return null; 1468 } 1469 1470 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1471 } 1472 1473 /** 1474 * Creates a new #GParamSpecLong instance specifying a %G_TYPE_LONG property. 1475 * 1476 * See g_param_spec_internal() for details on property names. 1477 * 1478 * Params: 1479 * name = canonical name of the property specified 1480 * nick = nick name for the property specified 1481 * blurb = description of the property specified 1482 * minimum = minimum value for the property specified 1483 * maximum = maximum value for the property specified 1484 * defaultValue = default value for the property specified 1485 * flags = flags for the property specified 1486 * 1487 * Returns: a newly created parameter specification 1488 */ 1489 public static ParamSpec paramSpecLong(string name, string nick, string blurb, glong minimum, glong maximum, glong defaultValue, GParamFlags flags) 1490 { 1491 auto __p = g_param_spec_long(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1492 1493 if(__p is null) 1494 { 1495 return null; 1496 } 1497 1498 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1499 } 1500 1501 /** 1502 * Creates a new #GParamSpecBoxed instance specifying a %G_TYPE_OBJECT 1503 * derived property. 1504 * 1505 * See g_param_spec_internal() for details on property names. 1506 * 1507 * Params: 1508 * name = canonical name of the property specified 1509 * nick = nick name for the property specified 1510 * blurb = description of the property specified 1511 * objectType = %G_TYPE_OBJECT derived type of this property 1512 * flags = flags for the property specified 1513 * 1514 * Returns: a newly created parameter specification 1515 */ 1516 public static ParamSpec paramSpecObject(string name, string nick, string blurb, GType objectType, GParamFlags flags) 1517 { 1518 auto __p = g_param_spec_object(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), objectType, flags); 1519 1520 if(__p is null) 1521 { 1522 return null; 1523 } 1524 1525 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1526 } 1527 1528 /** 1529 * Creates a new property of type #GParamSpecOverride. This is used 1530 * to direct operations to another paramspec, and will not be directly 1531 * useful unless you are implementing a new base type similar to GObject. 1532 * 1533 * Params: 1534 * name = the name of the property. 1535 * overridden = The property that is being overridden 1536 * 1537 * Returns: the newly created #GParamSpec 1538 * 1539 * Since: 2.4 1540 */ 1541 public static ParamSpec paramSpecOverride(string name, ParamSpec overridden) 1542 { 1543 auto __p = g_param_spec_override(Str.toStringz(name), (overridden is null) ? null : overridden.getParamSpecStruct()); 1544 1545 if(__p is null) 1546 { 1547 return null; 1548 } 1549 1550 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p); 1551 } 1552 1553 /** 1554 * Creates a new #GParamSpecParam instance specifying a %G_TYPE_PARAM 1555 * property. 1556 * 1557 * See g_param_spec_internal() for details on property names. 1558 * 1559 * Params: 1560 * name = canonical name of the property specified 1561 * nick = nick name for the property specified 1562 * blurb = description of the property specified 1563 * paramType = a #GType derived from %G_TYPE_PARAM 1564 * flags = flags for the property specified 1565 * 1566 * Returns: a newly created parameter specification 1567 */ 1568 public static ParamSpec paramSpecParam(string name, string nick, string blurb, GType paramType, GParamFlags flags) 1569 { 1570 auto __p = g_param_spec_param(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), paramType, flags); 1571 1572 if(__p is null) 1573 { 1574 return null; 1575 } 1576 1577 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1578 } 1579 1580 /** 1581 * Creates a new #GParamSpecPointer instance specifying a pointer property. 1582 * Where possible, it is better to use g_param_spec_object() or 1583 * g_param_spec_boxed() to expose memory management information. 1584 * 1585 * See g_param_spec_internal() for details on property names. 1586 * 1587 * Params: 1588 * name = canonical name of the property specified 1589 * nick = nick name for the property specified 1590 * blurb = description of the property specified 1591 * flags = flags for the property specified 1592 * 1593 * Returns: a newly created parameter specification 1594 */ 1595 public static ParamSpec paramSpecPointer(string name, string nick, string blurb, GParamFlags flags) 1596 { 1597 auto __p = g_param_spec_pointer(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), flags); 1598 1599 if(__p is null) 1600 { 1601 return null; 1602 } 1603 1604 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1605 } 1606 1607 /** 1608 * Creates a new #GParamSpecString instance. 1609 * 1610 * See g_param_spec_internal() for details on property names. 1611 * 1612 * Params: 1613 * name = canonical name of the property specified 1614 * nick = nick name for the property specified 1615 * blurb = description of the property specified 1616 * defaultValue = default value for the property specified 1617 * flags = flags for the property specified 1618 * 1619 * Returns: a newly created parameter specification 1620 */ 1621 public static ParamSpec paramSpecString(string name, string nick, string blurb, string defaultValue, GParamFlags flags) 1622 { 1623 auto __p = g_param_spec_string(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), Str.toStringz(defaultValue), flags); 1624 1625 if(__p is null) 1626 { 1627 return null; 1628 } 1629 1630 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1631 } 1632 1633 /** 1634 * Creates a new #GParamSpecUChar instance specifying a %G_TYPE_UCHAR property. 1635 * 1636 * Params: 1637 * name = canonical name of the property specified 1638 * nick = nick name for the property specified 1639 * blurb = description of the property specified 1640 * minimum = minimum value for the property specified 1641 * maximum = maximum value for the property specified 1642 * defaultValue = default value for the property specified 1643 * flags = flags for the property specified 1644 * 1645 * Returns: a newly created parameter specification 1646 */ 1647 public static ParamSpec paramSpecUchar(string name, string nick, string blurb, ubyte minimum, ubyte maximum, ubyte defaultValue, GParamFlags flags) 1648 { 1649 auto __p = g_param_spec_uchar(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1650 1651 if(__p is null) 1652 { 1653 return null; 1654 } 1655 1656 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1657 } 1658 1659 /** 1660 * Creates a new #GParamSpecUInt instance specifying a %G_TYPE_UINT property. 1661 * 1662 * See g_param_spec_internal() for details on property names. 1663 * 1664 * Params: 1665 * name = canonical name of the property specified 1666 * nick = nick name for the property specified 1667 * blurb = description of the property specified 1668 * minimum = minimum value for the property specified 1669 * maximum = maximum value for the property specified 1670 * defaultValue = default value for the property specified 1671 * flags = flags for the property specified 1672 * 1673 * Returns: a newly created parameter specification 1674 */ 1675 public static ParamSpec paramSpecUint(string name, string nick, string blurb, uint minimum, uint maximum, uint defaultValue, GParamFlags flags) 1676 { 1677 auto __p = g_param_spec_uint(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1678 1679 if(__p is null) 1680 { 1681 return null; 1682 } 1683 1684 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1685 } 1686 1687 /** 1688 * Creates a new #GParamSpecUInt64 instance specifying a %G_TYPE_UINT64 1689 * property. 1690 * 1691 * See g_param_spec_internal() for details on property names. 1692 * 1693 * Params: 1694 * name = canonical name of the property specified 1695 * nick = nick name for the property specified 1696 * blurb = description of the property specified 1697 * minimum = minimum value for the property specified 1698 * maximum = maximum value for the property specified 1699 * defaultValue = default value for the property specified 1700 * flags = flags for the property specified 1701 * 1702 * Returns: a newly created parameter specification 1703 */ 1704 public static ParamSpec paramSpecUint64(string name, string nick, string blurb, ulong minimum, ulong maximum, ulong defaultValue, GParamFlags flags) 1705 { 1706 auto __p = g_param_spec_uint64(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1707 1708 if(__p is null) 1709 { 1710 return null; 1711 } 1712 1713 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1714 } 1715 1716 /** 1717 * Creates a new #GParamSpecULong instance specifying a %G_TYPE_ULONG 1718 * property. 1719 * 1720 * See g_param_spec_internal() for details on property names. 1721 * 1722 * Params: 1723 * name = canonical name of the property specified 1724 * nick = nick name for the property specified 1725 * blurb = description of the property specified 1726 * minimum = minimum value for the property specified 1727 * maximum = maximum value for the property specified 1728 * defaultValue = default value for the property specified 1729 * flags = flags for the property specified 1730 * 1731 * Returns: a newly created parameter specification 1732 */ 1733 public static ParamSpec paramSpecUlong(string name, string nick, string blurb, gulong minimum, gulong maximum, gulong defaultValue, GParamFlags flags) 1734 { 1735 auto __p = g_param_spec_ulong(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1736 1737 if(__p is null) 1738 { 1739 return null; 1740 } 1741 1742 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1743 } 1744 1745 /** 1746 * Creates a new #GParamSpecUnichar instance specifying a %G_TYPE_UINT 1747 * property. #GValue structures for this property can be accessed with 1748 * g_value_set_uint() and g_value_get_uint(). 1749 * 1750 * See g_param_spec_internal() for details on property names. 1751 * 1752 * Params: 1753 * name = canonical name of the property specified 1754 * nick = nick name for the property specified 1755 * blurb = description of the property specified 1756 * defaultValue = default value for the property specified 1757 * flags = flags for the property specified 1758 * 1759 * Returns: a newly created parameter specification 1760 */ 1761 public static ParamSpec paramSpecUnichar(string name, string nick, string blurb, dchar defaultValue, GParamFlags flags) 1762 { 1763 auto __p = g_param_spec_unichar(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), defaultValue, flags); 1764 1765 if(__p is null) 1766 { 1767 return null; 1768 } 1769 1770 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1771 } 1772 1773 /** 1774 * Creates a new #GParamSpecValueArray instance specifying a 1775 * %G_TYPE_VALUE_ARRAY property. %G_TYPE_VALUE_ARRAY is a 1776 * %G_TYPE_BOXED type, as such, #GValue structures for this property 1777 * can be accessed with g_value_set_boxed() and g_value_get_boxed(). 1778 * 1779 * See g_param_spec_internal() for details on property names. 1780 * 1781 * Params: 1782 * name = canonical name of the property specified 1783 * nick = nick name for the property specified 1784 * blurb = description of the property specified 1785 * elementSpec = a #GParamSpec describing the elements contained in 1786 * arrays of this property, may be %NULL 1787 * flags = flags for the property specified 1788 * 1789 * Returns: a newly created parameter specification 1790 */ 1791 public static ParamSpec paramSpecValueArray(string name, string nick, string blurb, ParamSpec elementSpec, GParamFlags flags) 1792 { 1793 auto __p = g_param_spec_value_array(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), (elementSpec is null) ? null : elementSpec.getParamSpecStruct(), flags); 1794 1795 if(__p is null) 1796 { 1797 return null; 1798 } 1799 1800 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p); 1801 } 1802 1803 /** 1804 * Creates a new #GParamSpecVariant instance specifying a #GVariant 1805 * property. 1806 * 1807 * If @default_value is floating, it is consumed. 1808 * 1809 * See g_param_spec_internal() for details on property names. 1810 * 1811 * Params: 1812 * name = canonical name of the property specified 1813 * nick = nick name for the property specified 1814 * blurb = description of the property specified 1815 * type = a #GVariantType 1816 * defaultValue = a #GVariant of type @type to 1817 * use as the default value, or %NULL 1818 * flags = flags for the property specified 1819 * 1820 * Returns: the newly created #GParamSpec 1821 * 1822 * Since: 2.26 1823 */ 1824 public static ParamSpec paramSpecVariant(string name, string nick, string blurb, VariantType type, Variant defaultValue, GParamFlags flags) 1825 { 1826 auto __p = g_param_spec_variant(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), (type is null) ? null : type.getVariantTypeStruct(), (defaultValue is null) ? null : defaultValue.getVariantStruct(true), flags); 1827 1828 if(__p is null) 1829 { 1830 return null; 1831 } 1832 1833 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) __p, true); 1834 } 1835 1836 /** 1837 * Return a newly allocated string, which describes the contents of a 1838 * #GValue. The main purpose of this function is to describe #GValue 1839 * contents for debugging output, the way in which the contents are 1840 * described may change between different GLib versions. 1841 * 1842 * Params: 1843 * value = #GValue which contents are to be described. 1844 * 1845 * Returns: Newly allocated string. 1846 */ 1847 public static string strdupValueContents(Value value) 1848 { 1849 auto retStr = g_strdup_value_contents((value is null) ? null : value.getValueStruct()); 1850 1851 scope(exit) Str.freeString(retStr); 1852 return Str.toString(retStr); 1853 } 1854 }